package com.lcredu.seckill.rabbitmq;

import com.lcredu.seckill.config.RabbitSeckillMessageConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author 黎长容
 * @date 2025-09-12 15:12
 * 生产者/发送者
 */
@Service
@Slf4j
public class SeckillMQSender {
    //这里发送一个seckillMessage的对象
    @Resource
    public RabbitTemplate rabbitTemplate;

    public void sendMessage(String seckillMessage) {
        System.out.println("注意这个消息--SeckillMQSender");
        log.info("发送了消息={}", seckillMessage);
        rabbitTemplate.convertAndSend(RabbitSeckillMessageConfig.SECKILLTOPICEXCHANGE01,
                "seckill.message", seckillMessage);
    }

}
